
import { dashborad } from '@/api/index.js'
export default {
    state: () => ({
        crmData: {},
        orderData: {},
        terminalData: {},
    }),
    getters: {
        //获取crm
        crm: state => {
            return state.crmData
        }
    },
    mutations: {
        updateCrmData(state, value) {
            state.crmData = value
        },
        updateOrderData(state, value) {
            state.orderData = value
        },
        updateTerminalData(state, value) {
            state.terminalData = value
        },

    },
    actions: {
        //筛选数据
        requstData({ commit, state }) {
            dashborad.getStatisticalData().then(res => {
                commit('updateCrmData', res.content)
                console.info(res,'crm info request')
             }).catch(e => {
                console.log(e, 'crm error>>>>>>');
            })
            dashborad.getDevices().then(res => {
                commit('updateTerminalData', res.content)
                console.info(res,'terminal info request')
             }).catch(e => {
                console.log(e, 'terminal error>>>>>>');
            })
            dashborad.getOrders().then(res => {
                commit('updateOrderData', res.content)
                console.info(res,'order info request')
             }).catch(e => {
                console.log(e, 'order error>>>>>>');
            })
        }
    },
}